package io.gitee.yxsnake.framework.core.enums;

import io.gitee.yxsnake.framework.core.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author snake
 * @description 登录类型
 * @since 2024/11/2 19:13
 */
@Getter
@AllArgsConstructor
public enum LoginType {

    /**
     * 密码登录
     */
    PASSWORD("user.password.retry.limit.exceed", "user.password.retry.limit.count"),

    /**
     * 短信登录
     */
    SMS("sms.code.retry.limit.exceed", "sms.code.retry.limit.count"),

    /**
     * 邮箱登录
     */
    EMAIL("email.code.retry.limit.exceed", "email.code.retry.limit.count"),

    /**
     * 小程序登录
     */
    XCX("", "");

    /**
     * 登录重试超出限制提示
     */
    final String retryLimitExceed;

    /**
     * 登录重试限制计数提示
     */
    final String retryLimitCount;

    public static LoginType getInstance(String str) {
        for (LoginType value : values()) {
            if (StringUtils.contains(str, value.getRetryLimitExceed())) {
                return value;
            }
        }
        throw new RuntimeException("'LoginType' not found By " + str);
    }
}

